#!/usr/bin/python

# include the contrib config file
import build_contrib
import os
import shutil

# set pkg info
PKG_NAME="polarssl"
PKG_VERSION="1.1.0"
PKG_ARCHIVE="tgz"

#
build_contrib.begin_build(PKG_NAME, PKG_VERSION)
build_contrib.do_extract(PKG_NAME, PKG_VERSION, PKG_ARCHIVE)
build_contrib.do_patch(PKG_NAME, PKG_VERSION)

# configure
if build_contrib.pushd("%s/%s-%s" % (build_contrib.BUILD_PREFIX, PKG_NAME, PKG_VERSION)) != 0: exit( 1 )
if os.system("cmake -DLIB_INSTALL_DIR=\"%s/lib\" -DCMAKE_INSTALL_PREFIX=%s -DCMAKE_BUILD_TYPE=%s ." % (build_contrib.INSTALL_PREFIX, build_contrib.INSTALL_PREFIX, build_contrib.CMAKE_BUILD_TYPE)) != 0 : build_contrib.popd_and_exit()
build_contrib.popd()

# build & install
if build_contrib.pushd("%s/%s-%s" % (build_contrib.BUILD_PREFIX, PKG_NAME, PKG_VERSION)) != 0: exit( 1 )
if os.system("make") != 0 : build_contrib.popd_and_exit()
if os.system("make install") != 0 : build_contrib.popd_and_exit()
build_contrib.popd()

build_contrib.end_build(PKG_NAME, PKG_VERSION)
